import { createRouter, createWebHistory } from 'vue-router'
import LoginPage from '../views/LoginPage.vue'; 
import ProductList from '../components/ProductList.vue'
import Product from '../components/Product.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Login',
      component: LoginPage,
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
    {
      path: '/product-list',
      name: 'ProductList',
      component: ProductList,
    },
    {
      path: '/product-details/:id',
      name: 'Product',
      component: Product,
      props: true, // 将路由参数作为 props 传递给组件
    },
  ],
})

export default router
